home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7625 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: cscsun3.larc.nasa.gov!hook
  2. From: hook@cscsun3.larc.nasa.gov (Ed Hook)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP: Illegal Pointer Arithmetic
  5. Date: 27 Feb 1996 20:27:36 GMT
  6. Organization: CSC/NASA Langley Research Center
  7. Distribution: world
  8. Message-ID: <4gvpfo$lht@reznor.larc.nasa.gov>
  9. References: <4gj0ug$730@news.one.net> <danpop.825121139@rscernix> <31306a18.309961701@nntp.ix.netcom.com> <4gq77b$bmo@reznor.larc.nasa.gov> <4gqija$bmo@reznor.larc.nasa.gov> <31331425.52605482@nntp.ix.netcom.com>
  10. Reply-To: hook@cscsun3.larc.nasa.gov
  11. NNTP-Posting-Host: cscsun3.larc.nasa.gov
  12.  
  13. In article <31331425.52605482@nntp.ix.netcom.com>, miker3@ix.netcom.com (Mike Rubenstein) writes:
  14.  
  15.   [ much stuff deleted -- the unfortunate detritus of two (count 'em -- two)
  16.     posts in which I publicly made a fool of myself commenting on Schildt's
  17.     code: ]
  18. |> 
  19. |> > |> |> 
  20. |> > |> |>         do {
  21. |> > |> |>           ch = fgetc(fp);
  22. |> > |> |>           /* ... */
  23. |> > |> |>         } while (!feof(fp));
  24. |> > |> |> 
  25. |> 
  26. |> Actually, it fails on every input file since it goes through the loop
  27. |> after reaching EOF.  An empty file is just one example.  On a one
  28. |> character file it goes through the loop twice, once with the character
  29. |> and once with EOF.
  30. |> 
  31. |> Unless, of course, the unshown code includes a test for ch == EOF, but
  32. |> that would be contrary to the concept of an example.  feof() returns
  33. |> nonzero only after end of file has been reached.
  34. |> 
  35.   Hopefully, this is my year's quota of egregious stupidity ...
  36.  
  37.   Thanks to the comp.lang.c community, which forbore to flame me 
  38.   mercilessly.
  39.  
  40. |> 
  41. |> Michael M Rubenstein
  42.  
  43. -- 
  44.  Ed Hook                              |       Coppula eam, se non posit
  45.  Computer Sciences Corporation        |         acceptera jocularum.
  46.  NASA Langley Research Center         | Me? Speak for my employer?...<*snort*>
  47.  Internet: hook@cscsun3.larc.nasa.gov |        ... Get a _clue_ !!! ...
  48.